#include "catch.hpp"
#include "inelastic/e_mu_ep_util/mainLoop.h"
#include "generalTools/testing.h"


TEST_CASE( " mu-E' ordering " ){
  int imax = 20, lat = 0, iinc = 2, lasym = 0;
  double tev = 2.5507297688e-2, tol = 0.05;
  std::vector<double> 
  alphas { 1.1, 2.2, 3.3, 4.5, 5.8 },
  betas { 0.1, 0.2, 1.3, 1.4, 2.5, 2.6, 3.7 },
  sab {-0.18259619, -0.30201347, -3.93654779, -3.98809174, -4.33545607, 
  -4.39515402, -5.88934921, -0.76225291, -0.81658341, -3.14161459, -3.30566186, 
  -3.90554652, -3.96233362, -5.23696660, -1.19182884, -1.23155471, -2.79610565, 
  -2.95633099, -3.74989225, -3.80837585, -4.93373911, -1.58342860, -1.61310713, 
  -2.71233943, -2.84291608, -3.69699590, -3.75199349, -4.77433858, -1.96121202, 
  -1.98720663, -2.78454600, -2.88531460, -3.71288120, -3.77142141, -4.71158392 };

  double az = 0.99917, sigma_b = 163.72792237, sigma_b2 = 0.0, teff = 0.120441926;
  double enow = 1e-5;
  std::vector<double> correct_uj {-1, -0.75, -0.625, -0.5, -0.375, -0.25, -0.125, 
                                   0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 1 };
  std::vector<double> boundXsVec { sigma_b, sigma_b2 };

  GIVEN( "various incoming energies" ){
    std::vector<double> 
      enowVec     { 1e-6, 1e-5, 1e-4, 1e-2, 1e0 },
      correctXSI  { 6325.19417, 2004.20546, 648.031082, 123.589093, 40.2279794 },
      correctUBAR { 2.837173E-3, 0.009034, 0.03141817, 9.0734245E-2, 0.5481087 };

    THEN( "preliminary uj vector is correctly generated, as is xs (xsi) and ubar" ){
      for (size_t i = 0; i < enowVec.size(); ++i){
        auto out = do_530_etc(enowVec[i],tev,tol,lat,iinc,lasym,alphas,betas,sab,az,boundXsVec,teff);
        REQUIRE( correctXSI[i] == Approx(std::get<0>(out)).epsilon(1e-6) );
        REQUIRE( correctUBAR[i] == Approx(std::get<1>(out)).epsilon(1e-6) );
        REQUIRE( ranges::equal(correct_uj,std::get<2>(out),equal) );
      }
    } // THEN
  } // GIVEN

  GIVEN( "various tolerances" ){
    enow = 1e-2;
    std::vector<double> 
      toleranceVec { 1.0, 5.0, 10.0 }, 
      correctXSI   { 122.347462,  143.754642, 145.794799 }, 
      correctUBAR  { 0.024551863, 0.038463983, 0.050169921 };
    for ( size_t i = 0; i < toleranceVec.size(); ++i ){
      auto out = do_530_etc(enow,tev,toleranceVec[i],lat,iinc,lasym,alphas,betas,sab,az,boundXsVec,teff);
      REQUIRE( correctXSI[i] == Approx(std::get<0>(out)).epsilon(1e-6) );
      REQUIRE( correctUBAR[i] == Approx(std::get<1>(out)).epsilon(1e-6) );
      REQUIRE( ranges::equal(correct_uj,std::get<2>(out),equal) );
    }
  } // GIVEN
} // TEST CASE







TEST_CASE( "E-mu-E' ordering " ){
  int imax = 20, lat = 0, iinc = 2, lasym = 0;
  double tev = 2.5507297688e-2, tol = 0.05;
  std::vector<double> 
  alphas { 1.1, 2.2, 3.3, 4.5, 5.8 },
  betas { 0.1, 0.2, 1.3, 1.4, 2.5, 2.6, 3.7 },
  sab {-0.18259619, -0.30201347, -3.93654779, -3.98809174, -4.33545607, 
  -4.39515402, -5.88934921, -0.76225291, -0.81658341, -3.14161459, -3.30566186, 
  -3.90554652, -3.96233362, -5.23696660, -1.19182884, -1.23155471, -2.79610565, 
  -2.95633099, -3.74989225, -3.80837585, -4.93373911, -1.58342860, -1.61310713, 
  -2.71233943, -2.84291608, -3.69699590, -3.75199349, -4.77433858, -1.96121202, 
  -1.98720663, -2.78454600, -2.88531460, -3.71288120, -3.77142141, -4.71158392 };

  double az = 0.99917, sigma_b = 163.72792237, sigma_b2 = 0.0, teff = 0.120441926;
  std::vector<double> correct_uj = {-1, -0.75, -0.625, -0.5, -0.375, -0.25, -0.125, 
                                    0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 1 };
  std::vector<double> boundXsVec { sigma_b, sigma_b2 };

  GIVEN( "low tolerance" ){
    tol = 0.05;
    WHEN( "we consider various incoming energies" ){
      double enow = 1e-2;
      auto out = mu_ep(enow,tev,tol,lat,iinc,lasym,alphas,betas,sab,az,boundXsVec,teff);
      auto totalSCR = std::get<1>(out);
      std::vector<double> 
      correctSCR_0 = { 0, 0, 4.30920E-10, 2.091391E-3, 8.61840E-10, 2.957775E-3, 
      1.72368E-9, 4.18313E-3, 2.29057E-7, 0.048307, 4.563910E-7, 0.0682449, 
      9.11058E-7, 0.0965352, 1.820393E-6, 0.136688, 3.639062E-6, 0.1937401, 
      7.27640E-6, 0.2749550, 1.455108E-5, 0.390931, 2.910043E-5, 0.5573850, 
      5.81991E-5, 0.7982454, 1.163966E-4, 1.151470, 2.327914E-4, 1.6810476, 
      4.65581E-4, 2.5043561, 9.311603E-4, 3.861189, 1.862319E-3, 6.3080120, 
      3.72463E-3, 11.339248, 5.586953E-3, 15.33983, 7.449270E-3, 16.867670, 
      0.01255073, 15.959396, 0.0151014, 14.22409, 0.0186087, 9.9103291, 
      0.02211597, 7.1951112, 0.0256232, 5.220540, 0.0291304, 4.1565618, 
      0.03614498, 2.7622054, 0.0431594, 1.799198, 0.0457102, 1.5402397, 
      0.05973923, 0.8617446, 0.0737682, 0.499442, 0.0763189, 0.4546191, 
      0.07982623, 0.3947405, 0.0807030, 0.380275, 0.0809222, 0.3766967, 
      0.08092396, 0.3766688, 0.0809248, 0.376654, 0.0809248, 0.3766540, 
      0.08092490, 0.3766536, 0.0809249, 0.227186, 0.0809250, 0.2271854, 
      0.08092524, 0.2271836, 0.0809256, 0.227179, 0.0809291, 0.2271507, 
      0.08093595, 0.2270922, 0.0809496, 0.226975, 0.0809770, 0.2267415, 
      0.08103185, 0.2262748, 0.0811414, 0.225344, 0.0815798, 0.2216590, 
      0.08333348, 0.2075007, 0.0903479, 0.159232 }, 
      correctSCR_2 { 0, 0, 1.104587E-9, 3.348397E-3, 2.209175E-9, 4.735512E-3, 
      4.418349E-9, 6.697354E-3, 2.317519E-7, 0.04855694, 4.590855E-7, 0.06837779, 
      9.137526E-7, 0.09654190, 1.823087E-6, 0.13651965,  3.641755E-6, 0.19327509, 
      7.279092E-6, 0.27394354, 1.455377E-5, 0.3888738,   2.910311E-5, 0.55331018, 
      5.820181E-5, 0.79030441, 1.163992E-4, 1.13623631,  2.327940E-4, 1.65242632, 
      4.655835E-4, 2.45229571, 9.311627E-4, 3.77190447,  1.862321E-3, 6.17487363, 
      3.724637E-3, 11.2340743, 5.586954E-3, 16.9101287,  7.449270E-3, 19.5371096, 
      0.01255073,  19.0269439, 0.01510146,  16.7865802,  0.01860871,  11.2246444, 
      0.02211597,  7.82352113, 0.02562322,  5.66216515,  0.02913047,  4.21384864, 
      0.03614498,  2.48184627, 0.04315949,  1.64769203,  0.04571022,  1.41368180, 
      0.05973923,  0.84270638, 0.07376824,  0.50196392,  0.07631897,  0.46014534, 
      0.09034799,  0.25215334 }, 
      correctSCR_5 { 0, 0, 6.981995E-9, 8.418356E-3, 1.396399E-8, 0.01190578, 
      2.792798E-8, 0.01683818, 7.449270E-3, 21.4382910, 0.01255073, 22.9919788, 
      0.01510146, 20.0251088, 0.01860871, 12.7658125, 0.02211597, 8.44229035, 
      0.02562322, 5.79024532, 0.02913047, 4.11121686, 0.03263773, 3.01403869, 
      0.03614498, 2.27463937, 0.04315949, 1.36850860, 0.04571022, 1.18190684, 
      0.07376824, 0.49018879, 0.07631897, 0.4507353, 0.09034799, 0.25055336, 
      0.09736249, 0.17403347 };
  
      REQUIRE( ranges::equal(std::get<0>(out),correct_uj,equal) );
      REQUIRE( ranges::equal(totalSCR[0],correctSCR_0,equal) );
      REQUIRE( ranges::equal(totalSCR[2],correctSCR_2,equal) );
      REQUIRE( ranges::equal(totalSCR[5],correctSCR_5,equal) );


      enow = 1e-5;
      out = mu_ep(enow,tev,tol,lat,iinc,lasym,alphas,betas,sab,az,boundXsVec,teff);
      totalSCR = std::get<1>(out);
      correctSCR_0 = { 0, 0, 4.30920E-13, 0.01464430, 8.61840E-13, 0.02070840, 
      1.72368E-12, 0.02928255, 1.950040E-8, 2.98444322, 3.899907E-8, 4.14807360, 
      7.799641E-8, 5.727121, 1.559911E-7, 7.836590, 3.119805E-7, 10.59647, 
      6.239592E-7, 14.11041, 1.247917E-6, 18.43260, 2.495832E-6, 23.52853, 
      4.991662E-6, 29.24423, 9.983321E-6, 35.30389, 1.996664E-5, 41.34688, 
      3.993328E-5, 46.99049, 7.986656E-5, 51.88072, 1.597331E-4, 55.68775, 
      3.194662E-4, 58.01759, 6.389325E-4, 58.23229, 1.277865E-3, 55.22147, 
      2.555730E-3, 47.37324, 5.111460E-3, 33.56961, 5.111567E-3, 24.21925, 
      5.111674E-3, 24.21895, 5.111888E-3, 24.21834, 5.112316E-3, 24.21712, 
      5.113172E-3, 24.21469, 5.114885E-3, 24.20982, 5.118310E-3, 24.20009, 
      5.125160E-3, 24.18064, 5.138860E-3, 24.14177, 5.166260E-3, 24.06417, 
      5.221061E-3, 23.90952, 5.330663E-3, 23.60246, 5.549866E-3, 22.99755, 
      5.988273E-3, 21.82598, 6.865086E-3, 19.64117, 8.618713E-3, 15.89227, 
      0.0121259, 10.474070, 0.0156332, 7.0091835, 0.0191404, 4.7689751, 
      0.0226477, 3.2968758, 0.0261549, 2.3132472, 0.0296622, 1.6209341, 
      0.0331694, 1.1680969, 0.0357202, 1.1339294, 0.0497492, 1.0901183, 
      0.0637782, 0.7855959, 0.0663289, 0.7303015, 0.0803579, 0.4152573, 
      0.0873725, 0.2876547 };
      std::vector<double> correctSCR_13;
      correctSCR_13 = { 0, 0, 9.76841E-9, 2.257618, 1.953682E-8, 3.223989, 
      3.907364E-8, 4.622707, 7.81472E-8, 6.666377, 1.56294E-7, 9.691560, 
      3.125891E-7, 14.24913, 6.25178E-7, 21.27042, 1.25035E-6, 32.34316, 
      2.500713E-6, 49.89208, 5.00142E-6, 75.31986, 1.00028E-5, 99.90327, 
      2.000570E-5, 106.3916, 4.00114E-5, 99.25737, 8.00228E-5, 90.26702, 
      1.600456E-4, 82.73290, 3.20091E-4, 76.26774, 6.40182E-4, 69.62522, 
      1.280365E-3, 61.19261, 2.56073E-3, 49.18153, 5.11146E-3, 32.81199, 
      5.111567E-3, 24.21924, 5.11167E-3, 24.21892, 5.11188E-3, 24.21828, 
      5.112316E-3, 24.21699, 5.11317E-3, 24.21443, 5.11488E-3, 24.20931, 
      5.118310E-3, 24.19906, 5.12516E-3, 24.17857, 5.13886E-3, 24.13764, 
      5.166260E-3, 24.05596, 5.22106E-3, 23.89330, 5.33066E-3, 23.57077, 
      5.549866E-3, 22.93705, 5.98827E-3, 21.71551, 6.86508E-3, 19.45576, 
      8.618713E-3, 15.62522, 0.01212597, 10.17862, 0.01563322, 6.748972, 
      0.0191404, 4.5563310, 0.0226477, 3.1284404, 0.0261549, 2.1816321, 
      0.0296622, 1.5353732, 0.0331694, 1.0921600, 0.0357202, 1.0717544, 
      0.0497492, 1.0512202, 0.0637782, 0.7717803, 0.0663289, 0.7180549, 
      0.0803579, 0.4082281, 0.0873725, 0.2827570 };
      REQUIRE( ranges::equal(std::get<0>(out),correct_uj,equal) );
      REQUIRE( ranges::equal(totalSCR[0],correctSCR_0,equal) );
      REQUIRE( ranges::equal(totalSCR[13],correctSCR_13,equal) );


      enow = 5.0;
      out = mu_ep(enow,tev,tol,lat,iinc,lasym,alphas,betas,sab,az,boundXsVec,teff);
      totalSCR = std::get<1>(out);
      correctSCR_0 = { 0, 0, 2.154601E-7, 1.514951E-4, 4.309201E-7, 2.142270E-4, 
      8.618402E-7, 3.029235E-4, 1.968234E-5, 1.445061E-3, 3.850283E-5, 2.019164E-3, 
      7.614383E-5, 2.835320E-3, 1.514258E-4, 3.989305E-3, 3.019898E-4, 5.613554E-3, 
      6.031177E-4, 7.887280E-3, 1.205374E-3, 0.01104333, 2.409885E-3, 0.01535882, 
      4.818909E-3, 0.02109429, 9.636956E-3, 0.02829520, 0.01927305, 0.03628273, 
      0.038545, 0.04265231, 0.07708962, 0.04232956, 0.15417837, 0.03012932, 
      0.231267, 0.01879896, 0.30835587, 0.01112764, 0.38544463, 6.402796E-3, 
      0.462533, 3.619745E-3, 0.53962213, 2.021977E-3, 0.61671088, 1.119722E-3, 
      0.693799, 6.160328E-4, 0.77088839, 3.371953E-4, 0.84797714, 1.838169E-4, 
      0.925065, 9.987087E-5, 1.00215460, 5.411107E-5, 1.07924340, 2.924926E-5, 
      1.156332, 1.577879E-5, 1.23342090, 8.497312E-6, 1.31050970, 4.569137E-6, 
      1.387598, 2.453644E-6, 1.46468720, 1.316070E-6 };
      std::vector<double> correctSCR_12;
      correctSCR_12 = { 0, 0, 1.22640580, 0.34830248, 1.83960870, 0.5624488, 
      2.146210, 0.59573748, 2.45281150, 0.53914596, 3.06601440, 0.26240295, 
      3.372615, 0.1402814, 3.52591660, 0.09609423, 3.67921730, 0.06309734, 
      3.832518, 0.03975582, 3.98581880, 0.02406462, 4.13911950, 0.01401192, 
      4.292420, 7.858471E-3, 4.44572090, 4.251094E-3, 4.59902160, 2.221250E-3, 
      4.675672, 1.585582E-3, 4.75232230, 1.122652E-3, 4.82897270, 7.885744E-4, 
      4.905623, 5.496150E-4, 4.933681, 4.806588E-4, 4.93623180, 4.748123E-4, 
      4.964289, 4.147833E-4, 4.96684050, 4.096975E-4, 4.99489850, 3.575098E-4, 
      4.997449, 3.530911E-4, 5.00255070, 3.183044E-4, 5.00510150, 2.905347E-4, 
      5.019130, 1.758308E-4, 5.03315950, 1.063861E-4, 5.03571020, 9.709551E-5, 
      5.049739, 5.873042E-5, 5.06376820, 3.551576E-5, 5.066319, 3.241096E-5, 
      5.080348, 1.959409E-5 };
      REQUIRE( ranges::equal(std::get<0>(out),correct_uj,equal) );
      REQUIRE( ranges::equal(totalSCR[0],correctSCR_0,equal) );
      REQUIRE( ranges::equal(totalSCR[12],correctSCR_12,equal) );




    } // WHEN
  } // GIVEN





  GIVEN( "higher tolerance" ){
    tol = 5.0;
    double enow = 1e-5;
    auto out = mu_ep(enow,tev,tol,lat,iinc,lasym,alphas,betas,sab,az,boundXsVec,teff);
    std::vector<double> uj = std::get<0>(out);
    std::vector<std::vector<double>> totalSCR = std::get<1>(out);

    std::vector<std::vector<double>> correctFull_SCR {
      {0, 0, 1.72368E-12, 0.0223895, 5.11146E-3, 25.66746, 0.03316949, 0.8931319, 
               0.0357202, 0.867007, 0.06377824, 0.6006700, 0.06632897, 0.5583917},
      {0, 0, 3.06630E-12, 0.0298623, 5.11146E-3, 25.61133, 0.03316949, 0.8847224, 
               0.0357202, 0.860148, 0.06377824, 0.5991868, 0.06632897, 0.5570788},
      {0, 0, 4.41835E-12, 0.0358465, 5.11146E-3, 25.58036, 0.03316949, 0.8805317, 
               0.0357202, 0.856727, 0.06377824, 0.5984419, 0.06632897, 0.5564192},
      {0, 0, 6.91196E-12, 0.0448350, 5.11146E-3, 25.54736, 0.03316949, 0.8763505, 
               0.0357202, 0.853311, 0.06377824, 0.5976948, 0.06632897, 0.5557575},
      {0, 0, 1.23199E-11, 0.0598577, 5.11146E-3, 25.51226, 0.03316949, 0.8721788, 
               0.0357202, 0.849901, 0.06377824, 0.5969456, 0.06632897, 0.5550937},
      {0, 0, 2.79280E-11, 0.0901229, 5.11146E-3, 25.47498, 0.03316949, 0.8680166, 
               0.0357202, 0.846496, 0.06377824, 0.5961942, 0.06632897, 0.5544279},
      {0, 0, 1.16497E-10, 0.1840628, 5.11146E-3, 25.43545, 0.03316949, 0.8638641, 
               0.0357202, 0.843098, 0.06377824, 0.5954407, 0.06632897, 0.5537600},
      {0, 0, 2.560730E-3, 37.026722, 5.11146E-3, 25.39358, 0.03316949, 0.8597213, 
               0.0357202, 0.839704, 0.06377824, 0.5946850, 0.06632897, 0.5530900},
      {0, 0, 2.560730E-3, 37.126663, 5.11146E-3, 25.34928, 0.03316949, 0.8555882, 
               0.0357202, 0.836317, 0.06377824, 0.5939272, 0.06632897, 0.5524180},
      {0, 0, 2.560730E-3, 37.225371, 5.11146E-3, 25.30247, 0.03316949, 0.8514648, 
               0.0357202, 0.832935, 0.06377824, 0.5931672, 0.06632897, 0.5517440},
      {0, 0, 2.560730E-3, 37.322684, 5.11146E-3, 25.25305, 0.03316949, 0.8473513, 
               0.0357202, 0.829560, 0.06377824, 0.5924052, 0.06632897, 0.5510680},
      {0, 0, 2.560730E-3, 37.418426, 5.11146E-3, 25.20093, 0.03316949, 0.8432477, 
               0.0357202, 0.826190, 0.06377824, 0.5916411, 0.06632897, 0.5503899},
      {0, 0, 2.560730E-3, 37.512403, 5.11146E-3, 25.14601, 0.03316949, 0.8391540, 
               0.0357202, 0.822826, 0.06377824, 0.5908748, 0.06632897, 0.5497099},
      {0, 0, 2.560730E-3, 37.604408, 5.11146E-3, 25.08819, 0.03316949, 0.8350702, 
               0.0357202, 0.819468, 0.06377824, 0.5901065, 0.06632897, 0.5490278},
      {0, 0, 2.560730E-3, 37.781574, 5.11146E-3, 24.96338, 0.03316949, 0.8269329, 
               0.0357202, 0.812769, 0.06377824, 0.5885638, 0.06632897, 0.5476578} };

    REQUIRE( ranges::equal(std::get<0>(out),correct_uj,equal) );
    for ( size_t i = 0; i < totalSCR.size(); ++i ){
      REQUIRE( ranges::equal(correctFull_SCR[i],totalSCR[i],equal) );
    }


    enow = 8.7e-4;
    correctFull_SCR = { 
    {0,0,1.49960E-10, 0.0188856, 5.97146E-3, 24.42644, 0.0340294, 1.174695, 
          0.03658022, 1.0791822, 0.06463824, 0.605796, 0.0671889, 0.560480}, 
    {0,0,2.66768E-10, 0.0251889, 5.97146E-3, 24.92099, 0.0340294, 1.091499, 
          0.03658022, 1.0139388, 0.06463824, 0.595800, 0.0671889, 0.551809}, 
    {0,0,3.84396E-10, 0.0302366, 5.97146E-3, 25.15591, 0.0340294, 1.050469, 
          0.03658022, 0.9815694, 0.06463824, 0.590457, 0.0671889, 0.547150}, 
    {0,0,6.01340E-10, 0.0378184, 5.97146E-3, 25.37616, 0.0340294, 1.009912, 
          0.03658022, 0.9494328, 0.06463824, 0.584894, 0.0671889, 0.542284}, 
    {0,0,1.071832E-9, 0.0504901, 5.97146E-3, 25.57477, 0.0340294, 0.969895, 
          0.03658022, 0.9175744, 0.06463824, 0.579119, 0.0671889, 0.537217}, 
    {0,0,2.429734E-9, 0.0760189, 5.97146E-3, 25.74228, 0.0340294, 0.930477, 
          0.03658022, 0.8860379, 0.06463824, 0.573137, 0.0671889, 0.531956}, 
    {0,0,1.013520E-8, 0.1552582, 5.97146E-3, 25.86576, 0.0340294, 0.891718, 
          0.03658022, 0.8548643, 0.06463824, 0.566957, 0.0671889, 0.526506}, 
    {0,0,3.420730E-3, 34.962778, 5.97146E-3, 25.92733, 0.0340294, 0.853670, 
          0.03658022, 0.8240924, 0.06463824, 0.560587, 0.0671889, 0.520876}, 
    {0,0,3.420730E-3, 36.069679, 5.97146E-3, 25.90197, 0.0340294, 0.816381, 
          0.03658022, 0.7937588, 0.06463824, 0.554034, 0.0671889, 0.515071}, 
    {0,0,3.420730E-3, 37.241349, 5.97146E-3, 25.75422, 0.0340294, 0.779895, 
          0.03658022, 0.7638975, 0.06463824, 0.547307, 0.0671889, 0.509100}, 
    {0,0,3.420730E-3, 38.455865, 5.97146E-3, 25.43307, 0.0340294, 0.744252, 
          0.03658022, 0.7345402, 0.06463824, 0.540414, 0.0671889, 0.502969}, 
    {0,0,3.420730E-3, 39.656477, 5.97146E-3, 24.86395, 0.0340294, 0.709486, 
          0.03658022, 0.7057159, 0.06463824, 0.533363, 0.0671889, 0.496685}, 
    {0,0,3.420730E-3, 40.705247, 5.97146E-3, 23.93617, 0.0340294, 0.675630, 
          0.03658022, 0.6774513, 0.06463824, 0.526163, 0.0671889, 0.490258}, 
    {0,0,3.420730E-3, 41.260985, 5.97146E-3, 22.48340, 0.0340294, 0.638436, 
          0.03658022, 0.6497708, 0.06463824, 0.515770, 0.0671889, 0.483693}, 
    {0,0,3.420730E-3, 35.469137, 5.97146E-3, 16.89347, 0.0340294, 0.564510, 
          0.03658022, 0.5899743, 0.06463824, 0.493578, 0.0671889, 0.464616} };
    out = mu_ep(enow,tev,tol,lat,iinc,lasym,alphas,betas,sab,az,boundXsVec,teff);
    uj = std::get<0>(out);
    totalSCR = std::get<1>(out);


    REQUIRE( ranges::equal(std::get<0>(out),correct_uj,equal) );
    for ( size_t i = 0; i < totalSCR.size(); ++i ){
      REQUIRE( ranges::equal(correctFull_SCR[i],totalSCR[i],equal) );
    }

    enow = 7.2e-3;
    correctFull_SCR = {
    { 0, 0, 1.241050E-9, 5.01355E-3, 4.64927E-3, 15.538869, 9.75073E-3, 16.94648, 
      0.0123014, 14.96677, 0.0403594, 1.546912, 0.0429102, 1.3279134, 0.0709682, 
      0.468007, 0.0735189, 0.428618 }, {0, 0, 2.207738E-9, 6.6869E-3, 4.64927E-3, 
      16.514318, 9.75073E-3, 18.634842, 0.0123014, 16.37620, 0.0403594, 1.421308, 
      0.0429102, 1.2273069, 0.0709682, 0.465587, 0.0735189, 0.427647 }, { 0, 0, 
      3.181211E-9, 8.02689E-3, 4.64927E-3, 17.075947, 9.75073E-3, 18.915349, 
      0.0123014, 17.14796, 0.0403594, 1.350299, 0.0429102, 1.1683207, 0.0709682, 
      0.462843, 0.0735189, 0.425549}, {0, 0, 4.976609E-9, 0.01003964, 4.64927E-3, 
      17.69865, 9.75073E-3, 19.632336, 0.0123014, 17.96869, 0.0403594, 1.275241, 
      0.0429102, 1.1057750, 0.0709682, 0.459096, 0.0735189, 0.422394 }, { 0, 0, 
      8.870331E-9, 0.01340361, 4.64927E-3, 18.394249, 9.75073E-3, 20.437236, 
      0.0123014, 18.28819, 0.0403594, 1.197223, 0.0429102, 1.0405601, 0.0709682, 
      0.454373, 0.0735189, 0.418205}, {0, 0, 2.010814E-8, 0.02018082, 4.64927E-3, 
      19.177989, 9.75073E-3, 21.349518, 0.0123014, 18.28819, 0.0403594, 1.117321, 
      0.0429102, 0.9735615, 0.0709682, 0.448703, 0.0735189, 0.413014 }, { 0, 0, 
      8.387749E-8, 0.04121745, 4.64927E-3, 20.069904, 9.75073E-3, 22.395231, 
      0.0123014, 18.28819, 0.0403594, 1.019322, 0.0429102, 0.9030170, 0.0709682, 
      0.442006, 0.0735189, 0.40686}, {0, 0, 2.098541E-3, 12.5936173, 4.64927E-3, 
      21.096866, 9.75073E-3, 23.610132, 0.0123014, 18.28819, 0.0403594, 0.920269, 
      0.0429102, 0.8270573, 0.0709682, 0.431810, 0.0735189, 0.398681 }, { 0, 0, 
      2.09854E-3, 12.7606, 4.64927E-3, 22.29577, 9.75073E-3, 25.04481, 0.0123014, 
      18.28819, 0.0403594, 0.822258, 0.0429102, 0.7513132, 0.0709682, 0.420096, 
      0.0735189, 0.388436 }, { 0, 0, 2.098541E-3, 12.87502, 4.64927E-3, 23.71858, 
      9.75073E-3, 26.773513, 0.0123014, 18.28819, 0.0403594, 0.727094, 0.0429102, 
      0.6769434, 0.0709682, 0.407001, 0.0735189, 0.376899}, {0, 0, 2.098541E-3, 
      12.89509, 4.64927E-3, 25.44017, 9.75073E-3, 28.90989, 0.0123014, 18.28819, 
      0.0403594, 0.636302, 0.0429102, 0.6049639, 0.0709682, 0.392675, 0.0735189, 
      0.364201}, {0, 0, 2.098541E-3, 12.746306, 4.64927E-3, 27.56959, 9.75073E-3, 
      31.63690, 0.0123014, 18.28819, 0.0403594, 0.551094, 0.0429102, 0.5362316, 
      0.0709682, 0.376684, 0.0735189, 0.350485}, {0, 0, 2.098541E-3, 12.290114, 
      4.64927E-3, 30.257209, 9.75073E-3, 35.26353, 0.0123014, 18.28819, 0.0403594, 
      0.467848, 0.0429102, 0.4714344, 0.0709682, 0.352771, 0.0735189, 0.330828 }, 
      {0, 0, 2.098541E-3, 11.25717, 4.64927E-3, 33.614294, 9.75073E-3, 40.302936, 
      0.0123014, 18.28819, 0.0403594, 0.381834, 0.0429102, 0.3990583, 0.0709682, 
      0.326714, 0.0735189, 0.307092}, {0, 0, 2.098541E-3, 4.95869394, 4.64927E-3, 
      7.2680423, 9.75073E-3, 3.0418314, 0.0110261, 1.610056, 0.0116637, 1.228738, 
      0.0119826, 1.0819662, 0.0121420, 1.016991, 0.0122217, 0.986364, 0.0122616, 
      0.9714890, 0.0122815, 0.9641574, 0.0122915, 0.9605178, 0.0122964, 0.9587045, 
      0.0122989, 0.9577995, 0.0123002, 0.9573476, 0.0123008, 0.9571215, 0.0123011, 
      0.9570087, 0.0123013, 0.9569521, 0.0123013, 0.9569238, 0.0123014, 0.9569097, 
      0.0123014, 0.9569028, 0.0123014, 0.9568992, 0.0123014, 0.9568973, 0.0123014, 
      0.9568966, 0.0123014, 0.9568963, 0.0123014, 18.288192, 0.0263304, 1.3631208, 
      0.0403594, 0.2175854, 0.0429102, 0.2531586, 0.0709682, 0.2710199, 0.0735189, 
      0.2554516 } } ;
    out = mu_ep(enow,tev,tol,lat,iinc,lasym,alphas,betas,sab,az,boundXsVec,teff);
    uj = std::get<0>(out);
    totalSCR = std::get<1>(out);


    REQUIRE( ranges::equal(std::get<0>(out),correct_uj,equal) );
    for ( size_t i = 0; i < totalSCR.size(); ++i ){
      REQUIRE( ranges::equal(correctFull_SCR[i],totalSCR[i],equal) );
    }



    enow = 8.6e-1;
    correctFull_SCR = { 
  { 0, 0, 1.48236E-7, 2.312238E-3, 0.7936810, 3.730728E-3, 0.7962317, 3.655504E-3, 
    0.8242897, 2.921107E-3, 0.8268405, 2.86210E-3, 0.8548985, 2.28619E-3, 
    0.8574492, 2.239937E-3, 0.8625507, 1.98721E-3, 0.8651014, 1.79941E-3, 
    0.8931594, 6.036890E-4, 0.8957102, 5.46621E-4, 0.9237682, 1.83325E-4, 
    0.9263189, 1.659910E-4 }, 
  { 0, 0, 2.63702E-7, 3.083981E-3, 0.79368103, 9.403672E-3, 0.7962317, 9.227068E-3, 
    0.8242897, 7.486887E-3, 0.8268405, 7.34570E-3, 0.8548985, 5.95533E-3, 
    0.8574492, 5.842594E-3, 0.8625507, 5.19715E-3, 0.8651014, 4.71222E-3, 
    0.8931594, 1.603705E-3, 0.8957102, 1.45396E-3, 0.9237682, 4.94469E-4, 
    0.9263189, 4.482725E-4 }, 
  { 0, 0, 3.79978E-7, 3.701980E-3, 0.79368103, 0.01498382, 0.7962317, 0.01471285, 
    0.8242897, 0.01203002, 0.8268405, 0.0118112,  0.8548985, 9.647091E-3, 
    0.8574492, 9.47076E-3, 0.8625507, 8.43568E-3, 0.8651014, 7.653625E-3, 
    0.8931594, 2.62343E-3, 0.8957102, 2.38000E-3, 0.9237682, 8.150289E-4, 
    0.9263189, 7.39342E-4 }, 
  { 0, 0, 5.94428E-7, 4.630250E-3, 0.79368103, 0.02394515, 0.7962317, 0.02352887, 
    0.8242897, 0.0193872,  0.8268405, 0.0190477, 0.8548985, 0.01567384, 
    0.8574492, 0.0153976,  0.8625507, 0.0137329, 0.86510146, 0.01246800, 
    0.8931594, 4.30426E-3, 0.8957102, 3.907370E-3, 0.9237682, 1.347347E-3, 
    0.9263189, 1.22298E-3 }, 
  { 0, 0, 1.05951E-6, 6.181690E-3, 0.79368103, 0.03839740, 0.7962317, 0.03775692, 
    0.8242897, 0.03135235, 0.8268405, 0.0308246, 0.85489854, 0.02555451, 
    0.8574492, 0.02512084, 0.8625507, 0.0224347, 0.86510146, 0.02038167, 
    0.8931594, 7.08656E-3, 0.8957102, 6.437211E-3, 0.92376824, 2.235007E-3, 
    0.9263189, 2.02995E-3 }, 
  { 0, 0, 2.401806E-6, 9.307269E-3, 0.79368103, 0.06182400, 0.7962317, 0.06083666, 
    0.8242897, 0.05091179, 0.8268405, 0.0500896, 0.85489854, 0.04183711, 
    0.8574492, 0.04115450, 0.8625507, 0.0368026, 0.86510146, 0.03345681, 
    0.8931594, 0.01171568, 0.8957102, 0.0106488, 0.92376824, 3.722664E-3, 
    0.9263189, 3.38318E-3 }, 
  { 0, 0, 1.00187E-5, 0.01900873, 0.79368103, 0.10003529, 0.7962317, 0.09850953, 
    0.8242897, 0.08308778, 0.8268405, 0.0818030, 0.85489854, 0.06883954, 
    0.8574492, 0.06776147, 0.8625507, 0.0606763, 0.86510146, 0.05519649, 
    0.8931594, 0.01946577, 0.8957102, 0.0177044, 0.92376824, 6.231258E-3, 
    0.9263189, 5.66643E-3 }, 
  { 0, 0, 0.765623, 0.19100791, 0.79368103, 0.16285078, 0.7962317, 0.16048557, 
    0.8242897, 0.1364386, 0.82684051, 0.1344232, 0.85489854, 0.11397547, 
    0.8574492, 0.11226536, 0.8625507, 0.1006602, 0.86510146, 0.09162954, 
    0.8931594, 0.03254318, 0.8957102, 0.0296170, 0.92376824, 0.01049413, 
    0.9263189, 9.54857E-3 }, 
  { 0, 0, 0.7656230, 0.31068023, 0.79368103, 0.26715586, 0.79623176, 0.2634743, 
    0.8242897, 0.22580516, 0.8268405, 0.2226276, 0.85489854, 0.19019717, 
    0.8574492, 0.18746851, 0.8625507, 0.1683122, 0.86510146, 0.15331296, 
    0.8931594, 0.05483388, 0.8957102, 0.0499343, 0.92376824, 0.01781014, 
    0.9263189, 0.01621481 }, 
  { 0, 0, 0.7656230, 0.51027216, 0.79368103, 0.4426850, 0.79623176, 0.43692326, 
    0.8242897, 0.37754883, 0.8268405, 0.3725043, 0.85489854, 0.32068117, 
    0.8574492, 0.31629193, 0.8625507, 0.2843484, 0.86510146, 0.25917848, 
    0.8931594, 0.09334404, 0.8957102, 0.0850552, 0.92376824, 0.03053245, 
    0.9263189, 0.02781315 }, 
  { 0, 0, 0.7656230, 0.84919111, 0.79368103, 0.74361267, 0.79623176, 0.73452899, 
    0.8242897, 0.64013854, 0.8268405, 0.6320520, 0.85489854, 0.54835143, 
    0.8574492, 0.54120882, 0.8625507, 0.4871950, 0.86510146, 0.44436017, 
    0.8931594, 0.16113707, 0.8957102, 0.1469152, 0.92376824, 0.05306477, 
    0.9263189, 0.04836437 },
  { 0, 0, 0.7656230, 1.44002824, 0.79368103, 1.27385932, 0.79623176, 1.25939410, 
    0.8242897, 1.10749519, 0.8268405, 1.0943467, 0.85489854, 0.95698896, 
    0.8574492, 0.94516038, 0.8625507, 0.8519592, 0.86510146, 0.77755973, 
    0.8931594, 0.28384959, 0.8957102, 0.2589426, 0.92376824, 0.09406406, 
    0.9263189, 0.08577297 }, 
  { 0, 0, 0.7656230, 2.51390707, 0.79368103, 2.25023510, 0.79623176, 2.22688835, 
    0.8242897, 1.97801436, 0.8268405, 1.9561574, 0.85489854, 1.72490562, 
    0.8574492, 1.70474545, 0.8625507, 1.5386796, 0.86510146, 1.40521534, 
    0.8931594, 0.51621972, 0.8957102, 0.4711599, 0.92376824, 0.1719780, 
    0.9263189, 0.15687751 }, 
  { 0, 0, 0.7656230, 4.61756506, 0.79368103, 4.19959296, 0.79623176, 4.16139060, 
    0.8242897, 3.74288879, 0.8268405, 3.7051873, 0.85489854, 3.29754139, 
    0.8574492, 3.26127482, 0.8625507, 2.9474836, 0.86510146, 2.69350989, 
    0.8931594, 0.99484449, 0.8957102, 0.9083311, 0.92376824, 0.33238682, 
    0.9263189, 0.3032333 }, 
  { 0, 0, 0.765623, 0.4644803, 0.7936810, 1.6163610, 0.7962317, 1.5756257, 
    0.824289, 0.1315021, 0.8268405, 0.0552401, 0.8408695, 1.77410016, 0.847884, 
    14.591297, 0.8548985, 203.10478, 0.8548985, 0, 0.8548985, 0, 0.8548985, 0, 
    0.8548986, 0, 0.8548987, 0, 0.8548988, 0, 0.8548991, 0, 0.8548997, 0, 
    0.8549010, 0, 0.8549035, 0, 0.8549085, 0, 0.8549184, 0, 0.8549384, 0, 
    0.8549782, 0, 0.8550579, 0, 0.8552173, 0, 0.8555362, 0, 0.8561739, 0, 
    0.8574492, 0, 0.8625507, 0, 0.8638261, 0, 0.8644637, 0, 0.8647826, 0, 
    0.8649420, 0, 0.8650217, 0, 0.8650616, 0, 0.8650815, 0, 0.8650915, 0, 
    0.8650964, 0, 0.8650989, 0, 0.8651002, 0, 0.8651008, 0, 0.8651011, 0, 
    0.8651013, 0, 0.8651013, 0, 0.8651014, 0, 0.8651014, 0, 0.8651014, 167.277480, 
    0.87211597, 9.16573122, 0.87913048, 0.84601494, 0.8931594, 0.01496978, 
    0.89571022, 0.03244915, 0.92376824, 0.13304018, 0.9263189, 0.12359235 } };
  out = mu_ep(enow,tev,tol,lat,iinc,lasym,alphas,betas,sab,az,boundXsVec,teff);
  uj = std::get<0>(out);
  totalSCR = std::get<1>(out);


  REQUIRE( ranges::equal(std::get<0>(out),correct_uj,equal) );
  for ( size_t i = 0; i < totalSCR.size(); ++i ){
    REQUIRE( ranges::equal(correctFull_SCR[i],totalSCR[i],equal) );
  }



  enow = 1.42;
  correctFull_SCR = {
    {0, 0, 2.447626E-7, 2.755779E-3, 1.353681, 4.272026E-5, 1.35623180, 
     4.184456E-5, 1.38428980, 3.331706E-5, 1.38684050, 3.263371E-5, 1.41489850, 
     2.597966E-5, 1.41744930, 2.544648E-5, 1.42255070, 2.256232E-5, 1.42510150, 
     2.042413E-5, 1.45315950, 6.831062E-6, 1.45571020, 6.183648E-6, 1.48376820, 
     2.067926E-6, 1.486319, 1.871910E-6}, 
    {0, 0, 4.354149E-7, 3.675558E-3, 1.353681, 1.927324E-4, 1.35623180, 
     1.890414E-4, 1.38428980, 1.527900E-4, 1.38684050, 1.498585E-4, 1.41489850, 
     1.210726E-4, 1.41744930, 1.187453E-4, 1.42255070, 1.055658E-4, 1.42510150, 
     9.568792E-5, 1.45315950, 3.246857E-5, 1.45571020, 2.942958E-5, 1.48376820, 
     9.982303E-6, 1.486319, 9.047650E-6}, 
    {0, 0, 6.274056E-7, 4.412105E-3, 1.353681, 4.108631E-4, 1.35623180, 
     4.032727E-4, 1.38428980, 3.283974E-4, 1.38684050, 3.223146E-4, 1.41489850, 
     2.623289E-4, 1.41744930, 2.574572E-4, 1.42255070, 2.291855E-4, 1.42510150, 
     2.078778E-4, 1.45315950, 7.104638E-5, 1.45571020, 6.443838E-5, 1.48376820, 
     2.201213E-5, 1.486319, 1.996383E-5}, 
    {0, 0, 9.814979E-7, 5.518438E-3, 1.353681, 8.784507E-4, 1.35623180, 
     8.628185E-4, 1.38428980, 7.079299E-4, 1.38684050, 6.952880E-4, 1.41489850, 
     5.700791E-4, 1.41744930, 5.598640E-4, 1.42255070, 4.990452E-4, 1.42510150, 
     4.529475E-4, 1.45315950, 1.559218E-4, 1.45571020, 1.415112E-4, 1.48376820, 
     4.868248E-5, 1.486319, 4.418046E-5}, 
    {0, 0, 1.749426E-6, 7.367479E-3, 1.353681, 1.884677E-3, 1.35623180, 
     1.852424E-3, 1.38428980, 1.531405E-3, 1.38684050, 1.505079E-3, 1.41489850, 
     1.243189E-3, 1.41744930, 1.221724E-3, 1.42255070, 1.090450E-3, 1.42510150, 
     9.903772E-4, 1.45315950, 3.433852E-4, 1.45571020, 3.118505E-4, 1.48376820, 
     1.080399E-4, 1.486319, 9.811075E-5}, 
    {0, 0, 3.965773E-6, 0.01109262, 1.353681, 4.060136E-3, 1.35623180, 
     3.993436E-3, 1.38428980, 3.326493E-3, 1.38684050, 3.271534E-3, 1.41489850, 
     2.722334E-3, 1.41744930, 2.677107E-3, 1.42255070, 2.392620E-3, 1.42510150, 
     2.174480E-3, 1.45315950, 7.593712E-4, 1.45571020, 6.900793E-4, 1.48376820, 
     2.407586E-4, 1.486319, 2.187700E-4}, 
    {0, 0, 1.654251E-5, 0.02265504, 1.353681, 8.790276E-3, 1.35623180, 
     8.651936E-3, 1.38428980, 7.262042E-3, 1.38684050, 7.146939E-3, 1.41489850, 
     5.991393E-3, 1.41744930, 5.895774E-3, 1.42255070, 5.276235E-3, 1.42510150, 
     4.798356E-3, 1.45315950, 1.687731E-3, 1.45571020, 1.534713E-3, 1.48376820, 
     5.391884E-4, 1.486319, 4.902510E-4}, 
    {0, 0, 1.325623, 0.02260452, 1.353681, 0.01914824, 1.35623180, 0.01886022, 
     1.38428980, 0.01595214, 1.38684050, 0.01571007, 1.41489850, 0.01326819, 
     1.41744930, 0.01306512, 1.42255070, 0.01170771, 1.42510150, 0.01065435, 
     1.45315950, 3.774347E-3, 1.45571020, 3.434344E-3, 1.48376820, 1.214976E-3, 
     1.486319, 1.105389E-3}, 
    {0, 0, 1.325623, 0.04922816, 1.353681, 0.04203660, 1.35623180, 0.04143394, 
     1.38428980, 0.03531711, 1.38684050, 0.03480519, 1.41489850, 0.02961520, 
     1.41744930, 0.02918136, 1.42255070, 0.02618420, 1.42510150, 0.02384409, 
     1.45315950, 8.507243E-3, 1.45571020, 7.745810E-3, 1.48376820, 2.759135E-3, 
     1.486319, 2.511809E-3}, 
    {0, 0, 1.325623, 0.1082840, 1.353681, 0.09322511, 1.35623180, 0.09195549, 
     1.38428980, 0.07899664, 1.38684050, 0.07790581, 1.41489850, 0.06678745, 
     1.41744930, 0.06585290, 1.42255070, 0.05916762, 1.42510150, 0.05391524, 
     1.45315950, 0.01937296, 1.45571020, 0.01765011, 1.48376820, 6.329843E-3, 
     1.486319, 5.765908E-3}, 
    {0, 0, 1.325623, 0.24143499, 1.353681, 0.20962445, 1.35623180, 0.20692431, 
     1.38428980, 0.1791912, 1.38684050, 0.17684179, 1.41489850, 0.15275365, 
     1.41744930, 0.15071672, 1.42255070, 0.13559572, 1.42510150, 0.12363998, 
     1.45315950, 0.04473972, 1.45571020, 0.04078624, 1.48376820, 0.01472415, 
     1.486319, 0.01342017}, 
    {0, 0, 1.325623, 0.54890187, 1.353681, 0.48085803, 1.35623180, 0.47503586, 
     1.38428980, 0.41479374, 1.38684050, 0.40965222, 1.41489850, 0.35657555, 
     1.41744930, 0.35205624, 1.42255070, 0.31715525, 1.42510150, 0.2893807, 
     1.45315950, 0.10544036, 1.45571020, 0.09618088, 1.48376820, 0.03494273, 
     1.486319, 0.03186572}, 
    {0, 0, 1.325623, 1.28644916, 1.353681, 1.13817574, 1.35623180, 1.12535366, 
     1.38428980, 0.99139838, 1.38684050, 0.97985537, 1.41489850, 0.85965382, 
     1.41744930, 0.84932997, 1.42255070, 0.76614615, 1.42510150, 0.69950733, 
     1.45315950, 0.25658964, 1.45571020, 0.23418941, 1.48376820, 0.08557522, 
     1.486319, 0.07807746}, 
    {0, 0, 1.325623, 3.18304106, 1.353681, 2.85093036, 1.35623180, 2.82170770, 
     1.38428980, 2.51163110, 1.38684050, 2.48450398, 1.41489850, 2.19819464, 
     1.41744930, 2.17327997, 1.42255070, 1.96302656, 1.42510150, 1.79343449, 
     1.45315950, 0.6619243, 1.45571020, 0.60442823, 1.48376820, 0.22184068, 
     1.486319, 0.20246938}, 
    {0, 0, 1.325623, 0.444553, 1.353681, 1.821236, 1.356231, 1.778730, 
     1.384289, 0.122942, 1.386840, 0.047547, 1.400869, 2.041874, 1.407884, 
     19.39208, 1.414898, 311.4085, 1.414898, 0, 1.41489870, 0, 1.414898, 0, 
     1.414899, 0, 1.414899, 0, 1.414901, 0, 1.414903, 0, 1.414908, 0, 1.414918, 
     0, 1.414938, 0, 1.414978, 0, 1.415058, 0, 1.415217, 0, 1.415536, 0, 1.416173, 
     0, 1.417449, 0, 1.422550, 0, 1.423826, 0, 1.424463, 0, 1.424782, 0, 1.424942, 
     0, 1.425021, 0, 1.425061, 0, 1.425081, 0, 1.425091, 0, 1.425096, 0, 1.425099, 
     0, 1.425100, 0, 1.425100, 0, 1.425101, 0, 1.425101, 0, 1.425101, 255.876955, 
     1.432116, 12.13325, 1.439130, 0.970071, 1.453159, 0.012913, 1.455710, 
     0.03032921, 1.48376820, 0.1485215, 1.486319, 0.13766607}};
  out = mu_ep(enow,tev,tol,lat,iinc,lasym,alphas,betas,sab,az,boundXsVec,teff);
  uj = std::get<0>(out);
  totalSCR = std::get<1>(out);

  REQUIRE( ranges::equal(std::get<0>(out),correct_uj,equal) );
  for ( size_t i = 0; i < totalSCR.size(); ++i ){
    REQUIRE( ranges::equal(correctFull_SCR[i],totalSCR[i],equal) );
  }





  enow = 1.855;
  correctFull_SCR = {
    { 0, 0, 3.197427E-7, 3.314727E-3, 1.788681, 1.387546E-6, 1.7912318, 
      1.358945E-6, 1.8192898, 1.080651E-6, 1.8218405, 1.058369E-6, 1.8498985, 
      8.415617E-7, 1.8524493, 8.242027E-7, 1.8575507, 7.306319E-7},  
    { 0, 0, 5.687990E-7, 4.421064E-3, 1.788681, 9.837114E-6, 1.791231, 
      9.64748E-6, 1.819289, 7.78688E-6, 1.821840, 7.63658E-6, 1.849898, 
      6.16210E-6, 1.852449, 6.04301E-6, 1.857550, 5.37116E-6, 1.860101, 
      4.86807E-6, 1.888159, 1.65002E-6, 1.890710, 1.49544E-6, 1.918768, 5.067470e-7}, 
    { 0, 0, 8.196038E-7, 5.307002E-3, 1.788681, 2.628832E-5, 1.7912318, 
      2.579917E-5, 1.8192898, 2.097948E-5, 1.8218405, 2.058840E-5, 1.8498985, 
      1.673574E-5, 1.8524493, 1.642319E-5, 1.8575507, 1.461665E-5, 1.8601015, 
      1.325635E-5, 1.8881595, 4.525782E-6, 1.8907102, 4.104467E-6, 1.9187682, 
      1.400780E-6, 1.921319, 1.270332E-6}, 
    { 0, 0, 1.282168E-6, 6.637730E-3, 1.788681, 7.045934E-5, 1.7912318, 
      6.919563E-5, 1.8192898, 5.669071E-5, 1.8218405, 5.567143E-5, 1.8498985, 
      4.558788E-5, 1.8524493, 4.476619E-5, 1.8575507, 3.989477E-5, 1.8601015, 
      3.620588E-5, 1.8881595, 1.245040E-5, 1.8907102, 1.129872E-5, 1.9187682, 
      3.883558E-6, 1.921319, 3.524162E-6}, 
    { 0, 0, 2.285342E-6, 8.861808E-3, 1.788681, 1.895034E-4, 1.7912318, 
      1.862324E-4, 1.8192898, 1.537232E-4, 1.8218405, 1.510612E-4, 1.8498985, 
      1.246141E-4, 1.8524493, 1.224492E-4, 1.8575507, 1.092691E-4, 1.8601015, 
      9.923101E-5, 1.8881595, 3.437031E-5, 1.8907102, 3.121130E-5, 1.9187682, 
      1.080422E-5, 1.921319, 9.810645E-6}, 
    { 0, 0, 5.180640E-6, 0.01334251, 1.788681, 5.117807E-4, 1.7912318, 
      5.032933E-4, 1.8192898, 4.185668E-4, 1.8218405, 4.115968E-4, 1.8498985, 
      3.420477E-4, 1.8524493, 3.363288E-4, 1.8575507, 3.005249E-4, 1.8601015, 
      2.730975E-4, 1.8881595, 9.527577E-5, 1.8907102, 8.657505E-5, 1.9187682, 
      3.018196E-5, 1.921319, 2.742384E-5}, 
    { 0, 0, 2.16101E-5, 0.0272501, 1.788681, 1.389041E-3, 1.791231, 1.366950E-3,
      1.8192898, 1.145427E-3, 1.8218405, 1.127117E-3, 1.8498985, 9.436015E-4, 
      1.8524493, 9.284411E-4, 1.8575507, 8.307038E-4, 1.8601015, 7.553885E-4, 
      1.8881595, 2.654358E-4, 1.8907102, 2.413520E-4, 1.9187682, 8.473589E-5, 
      1.921319, 7.704133E-5}, 
    { 0, 0, 1.760623, 4.487795E-3, 1.788681, 3.793314E-3, 1.7912318, 3.735586E-3, 
      1.8192898, 3.153992E-3, 1.8218405, 3.105685E-3, 1.8498985, 2.619316E-3, 
      1.8524493, 2.578946E-3, 1.8575507, 2.310518E-3, 1.8601015, 2.102424E-3, 
      1.8881595, 7.440942E-4, 1.8907102, 6.770170E-4, 1.9187682, 2.393661E-4, 
      1.921319, 2.177674E-4}, 
    { 0, 0, 1.760623, 0.01225515, 1.788681, 0.01044015, 1.7912318, 0.01028849, 
      1.8192898, 8.753125E-3, 1.8218405, 8.624952E-3, 1.8498985, 7.328359E-3, 
      1.8524493, 7.220208E-3, 1.8575507, 6.477272E-3, 1.8601015, 5.897797E-3, 
      1.8881595, 2.102362E-3, 1.8907102, 1.914071E-3, 1.9187682, 6.814686E-4, 
      1.921319, 6.203649E-4}, 
    { 0, 0, 1.760623, 0.03380435, 1.788681, 0.02902808, 1.7912318, 0.02862678, 
      1.819289, 0.0245430, 1.821840, 0.0242002, 1.849898, 0.02071585, 1.852449, 
      0.0204237, 1.857550, 0.0183464, 1.860101, 0.01671616, 1.888159, 6.00138E-3, 
      1.89071, 5.46737E-3, 1.918768, 1.960012E-3, 1.921319, 1.78536E-3}, 
    { 0, 0, 1.760623, 0.09452992, 1.788681, 0.08183927, 1.7912318, 0.08076655, 
      1.8192898, 0.0697886, 1.8218405, 0.0688620, 1.8498985, 0.0593902, 1.852449, 
      0.0585917, 1.8575507, 0.0527023, 1.8601015, 0.0480507, 1.8881595, 0.0173736, 
      1.8907102, 0.0158377, 1.9187682, 5.716269E-3, 1.921319, 5.210058E-3}, 
    { 0, 0, 1.760623, 0.26960321, 1.788681, 0.23540729, 1.7912318, 0.2324966, 
      1.819289, 0.202517, 1.821840, 0.199970, 1.849898, 0.1737767, 1.8524493, 
      0.171554, 1.857550, 0.154515, 1.860101, 0.140969, 1.8881595, 0.0513286, 
      1.890710, 0.046819, 1.918768, 0.017009, 1.921319, 0.0155123}, 
    { 0, 0, 1.760623, 0.79302122, 1.788681, 0.69886477, 1.7912318, 0.69077996, 
      1.819289, 0.6068345, 1.821840, 0.5996438, 1.849898, 0.5251463, 1.852449, 
      0.5187792, 1.857550, 0.4678711, 1.860101, 0.4271358, 1.888159, 0.1565921, 
      1.890710, 0.1429204, 1.918768, 0.0522432, 1.921319, 0.0476693 }, 
    { 0, 0, 1.760623, 2.465449, 1.788681, 2.196821, 1.79123, 2.173441, 1.819289, 
      1.927694, 1.821840, 1.9063878, 1.849898, 1.6832205, 1.8524493, 1.6639405, 
      1.857550, 1.502646, 1.8601015, 1.372705, 1.8881595, 0.5064936, 1.8907102, 
      0.462514, 1.918768, 0.1699304, 1.921319, 0.1551155}, 
    { 0, 0, 0.8803115, 0.01194508, 1.3204673, 7.549987E-4, 1.5405452, 2.313576E-4, 
      1.650584, 1.502835E-4, 1.7056036, 1.334664E-4, 1.7331133, 1.317594E-4, 
      1.746868, 1.332812E-4, 1.7537456, 1.348322E-4, 1.7571843, 1.358439E-4, 
      1.758903, 1.364149E-4, 1.7597634, 1.367176E-4, 1.7601932, 1.368734E-4, 
      1.760408, 1.369524E-4, 1.7605156, 1.369921E-4, 1.7605693, 1.370121E-4, 
      1.760596, 1.370221E-4, 1.7606096, 1.370271E-4, 1.7606163, 1.370296E-4, 
      1.760619, 1.370309E-4, 1.7606214, 1.370315E-4, 1.7606222, 1.370318E-4, 
      1.760622, 1.370319E-4, 1.7606228, 1.370320E-4, 1.7606229, 1.370321E-4, 
      1.760623, 0.4755423, 1.788681, 2.123626, 1.791231, 2.076254, 1.819289, 
      0.129927, 1.8218405, 0.0480935, 1.835869, 2.4099586, 1.842884, 24.711248, 
      1.849898, 428.29811, 1.8498986, 0, 1.8498987, 0, 1.8498989, 0, 1.8498992, 0, 
      1.849899, 0, 1.849901, 0, 1.849903, 0, 1.849908, 0, 1.849918, 0, 1.849938, 0, 
      1.849978, 0, 1.850058, 0, 1.850217, 0, 1.850536, 0, 1.851173, 0, 1.852449, 0, 
      1.857550, 0, 1.858826, 0, 1.859463, 0, 1.859782, 0, 1.859942, 0, 1.860021, 0, 
      1.860061, 0, 1.860081, 0, 1.860091, 0, 1.860096, 0, 1.860099, 0, 1.860100, 0, 
      1.860100, 0, 1.860101, 0, 1.860101, 0, 1.860101, 351.62597, 1.867116, 15.43929, 
      1.87413, 1.1434019, 1.888159, 0.0130726, 1.890710, 0.03204937, 1.9187682, 
      0.17267, 1.921319, 0.15986281}};
  out = mu_ep(enow,tev,tol,lat,iinc,lasym,alphas,betas,sab,az,boundXsVec,teff);
  uj = std::get<0>(out);
  totalSCR = std::get<1>(out);

  REQUIRE( ranges::equal(std::get<0>(out),correct_uj,equal) );
  for ( size_t i = 0; i < totalSCR.size(); ++i ){
    REQUIRE( ranges::equal(correctFull_SCR[i],totalSCR[i],equal) );
  }


  } // GIVEN



} // TEST CASE

